package com.hn.birthdaymatch.controller;

import com.hn.birthdaymatch.model.Birthday;
import com.hn.birthdaymatch.result.PageResult;
import com.hn.birthdaymatch.result.Result;
import com.hn.birthdaymatch.service.BirthdayService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@Api(tags = "匹配模块")
@RequestMapping("/birthday")
public class BirthdayController {

    @Resource
    private BirthdayService birthdayService;


    @ApiOperation(value = "匹配模块-查询列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "params", value = "总字段包含以下所有参数,不传", required = false, dataType = "Map"),
            @ApiImplicitParam(name = "realName", value = "用户名", required = false, dataType = "String"),
            @ApiImplicitParam(name = "dyAccount", value = "抖音账号", required = false, dataType = "String"),
            @ApiImplicitParam(name = "year", value = "年(1900~2099)", required = false, dataType = "String"),
            @ApiImplicitParam(name = "month", value = "月(01~12)", required = false, dataType = "String"),
            @ApiImplicitParam(name = "day", value = "日(01~31)", required = false, dataType = "String"),
            @ApiImplicitParam(name = "orderBy", value = "排序字段：1 create_time", required = false, dataType = "String"),
            @ApiImplicitParam(name = "orderStyle", value = "排序字段：1 降序 0 升序", required = false, dataType = "String"),
            @ApiImplicitParam(name = "page", value = "分页起始位置", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "limit", value = "分页结束位置", required = true, dataType = "Integer")
    })
    @GetMapping
    public PageResult<Birthday> list(@RequestParam Map<String, Object> params) {
        return birthdayService.findList(params);
    }

    @ApiOperation("匹配模块-校验唯一标识")
    @PostMapping("/verifyUniIdentification")
    public Result verifyUniIdentification(@RequestBody Birthday birthday) {
        return birthdayService.verifyUniIdentification(birthday);
    }

    @ApiOperation("匹配模块-保存或修改")
    @PostMapping("/saveOrUpdateRole")
    public Result saveOrUpdateRole(@RequestBody Birthday birthday) {
        return birthdayService.saveOrUpdateRole(birthday);
    }

    @ApiOperation("匹配模块-删除")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "params", value = "总字段包含以下所有参数,不传", required = false, dataType = "Map"),
            @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "String"),
            @ApiImplicitParam(name = "uniIdentification", value = "唯一标识", required = false, dataType = "String"),
    })
    @DeleteMapping("/delete")
    public Result deleteBirthday(@RequestParam Map<String, Object> params) {
        return birthdayService.deleteBirthday(params);
    }

}
